\documentclass[a4paper]{article}
\usepackage{geometry}
\usepackage{listings}
\usepackage{graphicx}
\usepackage{float}
\usepackage{bm}
\title{HOMEWORK02-PROGRAMMING}
\author{3190101820 Weizhen Li}
\date{2021-10-28}
\geometry{left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm}
\lstset{numbers=left,basicstyle=\footnotesize,showstringspaces=false,otherkeywords={string},language = C++}
\begin{document}
\maketitle
\paragraph{Programming B}
~
\begin{lstlisting}[frame=shadowbox]
Programming B:
n = 2 the interpolation polynomial of f is: 
-0.0384615x^2+1

n = 4 the interpolation polynomial of f is: 
0.00530504x^4-0.171088x^2+1

n = 6 the interpolation polynomial of f is: 
-0.000840633x^6+8.67362e-19x^5+0.0335319x^4-0.351364x^2+2.77556e-17x+1

n = 8 the interpolation polynomial of f is: 
0.000137445x^8-0.00658016x^6+0.0981875x^4-6.93889e-17x^3-0.528121x^2+2.77556e-17x+1
\end{lstlisting}
The interpolation polynomials are shown above;the figure is as follows:(the curve described by '*' is the figure of $f(x)$)
\begin{figure}[H]
\includegraphics[width=15cm]{B.png}
\end{figure} 
\paragraph{Programming C}
~
\begin{lstlisting}[frame=shadowbox]
Programming C: 
n = 5 the interpolation polynomial of f is: 
2.7465x^4-3.54298x^2+2.22045e-16x+1

n = 10 the interpolation polynomial of f is: 
-3.64196e-14x^9+5.51277x^8+9.10478e-14x^7-14.0024x^6-5.5704e-14x^5+12.6193x^4
+3.06605e-14x^3-4.81162x^2-2.63684e-15x+0.730822

n = 15 the interpolation polynomial of f is: 
-333.619x^14-5.68434e-14x^13+1264.42x^12-9.09495e-13x^11-1927.18x^10+2.84217e-12x^9
+1510.61x^8+1.76215e-12x^7-646.864x^6+3.69482e-13x^5+149.027x^4-7.10543e-15x^3
-17.3641x^2+1.4988e-15x+1

n = 20 the interpolation polynomial of f is: 
3.19307e-12x^19-788.326x^18-1.66573e-11x^17+3973.16x^16+3.93281e-12x^15-8534.89x^14
-1.17966e-10x^13+10195.5x^12-6.12795e-11x^11-7413.45x^10-7.60981e-11x^9+3379.02x^8
-1.72285e-11x^7-960.825x^6-1.95768e-12x^5+165.458x^4+6.65006e-14x^3-16.5422x^2
+1.33568e-15x+0.96241
\end{lstlisting}
The interpolation polynomials are shown above;the figure is as follows:(the curve described by '.' is the figure of $f(x)$)
\begin{figure}[H]
	\includegraphics[width=15cm]{C.png}
\end{figure} 
\paragraph{Programming D}
~
\begin{lstlisting}[frame=shadowbox]
Programming D: 
(a):
The interpolation polynomial:
-2.02236e-05x^9+0.00104059x^8-0.0218757x^7+0.243041x^6-1.5383x^5+5.50812x^4-10.0953x^3
+7.16191x^2+75x
the position at t=10s is: 742.503
its speed at t=10s is: 48.3817
(b):
the derivative of this Hermite polynomial:
-0.000182013x^8+0.00832472x^7-0.15313x^6+1.45825x^5-7.69148x^4+22.0325x^3-30.2859x^2
+14.3238x+75
the value of deritative at t=6 is: 81.1029
So its maximun is bigger than 81, the car ever exceeded the speed limit! 
\end{lstlisting}
Just as above output shows :\\
(a)the position of the car is at the distance of 742.5 and its speed is 48.38 feet per second for t=10s.\\
(b)at t=6s,the value of its derivative i.e. its speed is 81.10 feet per second;so the car ever exceeded the speed limit.
\paragraph{Programming E}
~
\begin{lstlisting}[frame=shadowbox]
Programming E: 
(a):
the interpolation polynomial of Sample One:
4.1477e-05x^6-0.00371557x^5+0.128281x^4-2.11512x^3+16.2855x^2-43.0127x+6.67
the interpolation polynomial of Sample Two:
8.6768e-06x^6-0.000777473x^5+0.0265858x^4-0.424283x^3+2.98227x^2-5.85018x+6.67
(b):
For Sample One: the value of its curve at t=43 is: 14640.3
For Sample Two: the value of its curve at t=43 is: 2981.48
it is obviously unreasonable;investigate its monotonicity,easy to find that its prediction 
is not feasible! we can't predict this by interpolation polynomial; in fact,it is more 
possible that prediction near the interpolation points is more likely to be reasonable.
\end{lstlisting}
Just as above output shows:\\
(a)average weight curve of Sp1:\\
$4.1477\times10^{-05}x^{6}-0.00371557x^{5}+0.128281x^{4}-2.11512x^{3}+16.2855x^{2}-43.0127x+6.67$ \\
average weight curve of Sp2:\\
$8.6768\times10^{-06}x^{6}-0.000777473x^{5}+0.0265858x^{4}-0.424283x^{3}+2.98227x^{2}-5.85018x+6.67$\\
(b)after another 15 days i.e. day=43, the predictable average weight of Sp1 is 14640.3;\\
the predictable average of Sp2 is 2981.48;\\
it is obviously unreasonable;investigate its monotonicity,easy to find that its prediction 
is not feasible! we can't predict this by interpolation polynomial; in fact,it is more 
possible that prediction near the interpolation points is more likely to be reasonable.



\end{document}